package newfish.contacts.core.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import newfish.contacts.core.dao.impl.ContactDao;
import newfish.contacts.core.entity.impl.Contact;
import newfish.contacts.core.service.ContactService;

@Transactional(readOnly=true)
public class ContactServiceImpl implements ContactService {
	
	private ContactDao dao;

	public ContactDao getDao() {
		return dao;
	}

	public void setDao(ContactDao dao) {
		this.dao = dao;
	}

	@Override
	@Transactional(readOnly=false)
	public boolean create(Contact contact) {
		dao.create(contact);
		return true;
	}

	@Override
	@Transactional(readOnly=false)
	public boolean delete(Contact contact) {
		dao.delete(contact);
		return true;
	}

	@Override
	public Contact get(String id) {
		Contact contact = dao.findById(id);
		return contact;
	}

	@Override
	public List<Contact> listAll() {
		List<Contact> contactList = dao.listAll();
		return contactList;
	}

	@Override
	@Transactional(readOnly=false)
	public boolean update(Contact contact) {
		dao.update(contact);
		return true;
	}

}
